home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / abekas / readlabel.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  1KB  |  71 lines

  1. /* readlabel.c    1991 Abekas Video Systems  - Simon Carter */
  2. /*                                                          */
  3. /* This example reads the first block of the A60.           */
  4. /*                                                          */
  5. /*           cc -g readlabel.c -lds -o readlabel            */
  6.  
  7. #include <stdio.h>
  8. #include <fcntl.h>
  9. #include <dslib.h>
  10.  
  11. #define BLOCKSIZE 512
  12.  
  13. char *devpath = "/dev/scsi/sc0d5l0";       /* device for a60 */
  14. /*
  15. int dsreqflags;
  16. */
  17. int dsdebug;
  18. int dsblksize;
  19.  
  20. unsigned char block[BLOCKSIZE];
  21. int i, chunk, res;
  22. struct dsreq *dsp;
  23. char *ptr;
  24.  
  25. main(argc,argv)
  26. int argc;
  27. char **argv;
  28. {
  29. int i, j;
  30. char *ptr;
  31.  
  32. if(argc!=1) 
  33.     {
  34.     fprintf(stderr,"usage readlabel\n");
  35.     exit(1);
  36.     }
  37.  
  38. dsreqflags = DSRQ_SENSE | DSRQ_DISC;
  39. dsdebug = 0;
  40. dsblksize = BLOCKSIZE;
  41.  
  42. if ((dsp = dsopen(devpath,O_RDONLY)) == NULL)
  43.     {
  44.     fprintf(stderr, "unable to open %s\n", devpath);
  45.     exit(1);
  46.     }
  47.  
  48. /* clear check cond.    */
  49. if (testunitready00(dsp) != 0)
  50.     {
  51.     fprintf(stderr, "device not ready\n");
  52.     exit(1);
  53.     }
  54.  
  55. if(res = read08(dsp, block, 512, 0, 0))
  56.     {
  57.     fprintf(stderr, "error from read %d\n", i);
  58.     if (testunitready00(dsp) != 0)
  59.     fprintf(stderr, "device not ready\n");
  60.     exit(1);
  61.     }
  62.  
  63. ptr = block;
  64. for(i=0; i<32; i++)
  65.     {
  66.     for(j=0; j<16; j++)
  67.     printf("%02X ", 0xFF & *ptr++);
  68.     printf("\n");
  69.     }
  70. }
  71.